package com.example.demo.service;

import com.example.demo.common.utils.UUIDUtil;
import com.example.demo.dao.ProjectEntityMapper;
import com.example.demo.dao.entity.ProjectEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProjectService {
    @Autowired
    private ProjectEntityMapper projectEntityMapper;

    public List<ProjectEntity> queryProjectList(ProjectEntity projectEntity) {
        System.out.println(projectEntity);
        List<ProjectEntity> result;
        if(projectEntity.getProjectName() == null){
            result = projectEntityMapper.queryProjectList(projectEntity);
        }else{
            if(projectEntity.getProjectName().equals("")){
                result = projectEntityMapper.queryProjectList(projectEntity);
            }else{
                result = projectEntityMapper.searchProjectList(projectEntity);
            }
        }
        System.out.println("list"+result);
        return result;
    }

    public int addProjectInfo(ProjectEntity projectEntity) {
        projectEntity.setId(UUIDUtil.getOneUUID());
        int result = projectEntityMapper.insert(projectEntity);
        System.out.println("list"+result);
        return result;
    }

    public int modifyProjectInfo(ProjectEntity projectEntity){
        int projectResult = projectEntityMapper.updateByPrimaryKeySelective(projectEntity);
        return projectResult;
    }

    public int deleteUserById(ProjectEntity projectEntity){
        int projectResult = projectEntityMapper.deleteProjectById(projectEntity);
        return projectResult;
    }
}
